package com.slg.android.manyanime.bean;

import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by E540 on 2015/3/12.
 */
public class Channel {
    /**
     * 片单Id
     */
    private String id;
    /**
     * 片单名称
     */
    private String name;
    /**
     * 简介
     */
    private String intro;
    /**
     * 图片地址
     */
    private String pic;
    private String orderNum;
    private String type;
    private String del;
    private String used;
    private String count;
    /**
     * 可以为空
     */
    private String videos;
    /**
     * 添加时间
     */
    private String insertTime;

    public static List<Channel> parseData(JSONArray jsonArray) {
        ArrayList<Channel> list = new ArrayList<>();
        try {
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject channel = jsonArray.getJSONObject(i);
                Channel c = new Channel();
                c.setId(channel.getString("id"));
                c.setName(channel.getString("name"));
                c.setPic(channel.getString("pic"));
                c.setOrderNum(channel.getString("orderNum"));
                c.setType(channel.getString("type"));
                c.setDel(channel.getString("del"));
                c.setUsed(channel.getString("used"));
                c.setCount(channel.getString("count"));
                c.setVideos(channel.optString("videos"));
                c.setInsertTime(channel.getString("insert_time"));
                list.add(c);
            }
        } catch (JSONException e) {
            Log.e("解析出错", "错误信息", e);
        }

        return list;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDel() {
        return del;
    }

    public void setDel(String del) {
        this.del = del;
    }

    public String getUsed() {
        return used;
    }

    public void setUsed(String used) {
        this.used = used;
    }

    public String getCount() {
        return count;
    }

    public void setCount(String count) {
        this.count = count;
    }

    public String getVideos() {
        return videos;
    }

    public void setVideos(String videos) {
        this.videos = videos;
    }

    public String getInsertTime() {
        return insertTime;
    }

    public void setInsertTime(String insertTime) {
        this.insertTime = insertTime;
    }
}
